<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>小米商城-个人中心</title>
		<link rel="stylesheet" type="text/css" href="./css/style.css">
        <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.js"></script>
        <script type="text/javascript">


            //获取用户名字
            const GETUSER_URL="http://localhost:8080/mi/GetUser";
            const UPDATE_URL = "http://localhost:8080/mi/UpDateUser"; //保存新的的控制层
            const FINDDATE_URL = "http://localhost:8080/mi/findByName";//查询数据的控制层
            let name;

            //展示

                $(function () {
                    var name = localStorage.getItem("name");
                    $("#dlname").text(name).attr("href","self_info.html");

                    $.post(FINDDATE_URL, {name: name}, function (result) {
                        console.log(result)
                        $("#uid").attr("value", result.date.id)
                        $("#uname").attr("value", result.date.name);
                        $("#upassword").attr("value", result.date.password);
                        $("#uphone").attr("value", result.date.phone);
                        $("#uaddress").attr("value", result.date.address);
                        $("#uisdelete").attr("value", result.date.isDelete);
                    })

                    //点击提交按钮触发 将修改该后的数据保存到数据库
                    $("#subdate").click(function () {
                        var iid = $('#uid').val();
                        var iname = $('#uname').val();
                        var ipassword = $('#upassword').val();
                        var iphone = $('#uphone').val();
                        var iaddress = $('#uaddress').val();
                        var iisdelete = $('#uisdelete').val();

                        let user = {
                            id: iid,
                            name: iname,
                            password: ipassword,
                            phone: iphone,
                            address: iaddress,
                            isdelete: iisdelete
                        }
                        $.post(UPDATE_URL, user, function (save) {
                            if (save) {
                                //保存成功
                                alert("保存成功");
                            } else {
                                alert("保存失败");
                            }
                        })
                    })
                })






        </script>
	</head>
	<body>
	<!-- start header -->
		<header>
			<div class="top center">
				<div class="left fl">
					<ul>
						<li><a href="index.html" target="_blank">小米商城</a></li>

						<div class="clear"></div>
					</ul>
				</div>
				<div class="right fr">
					<div class="gouwuche fr"><a href="gouwuche.html">我的购物车</a></div>
					<div class="fr">
						<ul>
							<li><a id="dlname"  target="_blank">登录</a></li>
							<li>|</li>
							<li><a href="./register.html" target="_blank" >注册</a></li>
							<li>|</li>
							<li><a href="#top">个人中心</a></li>
						</ul>
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
		</header>
	<!--end header -->
	<!-- start banner_x -->
		<div class="banner_x center">
			<a href="./index.html" target="_blank"><div class="logo fl"></div></a>
			<a href=""><div class="ad_top fl"></div></a>
			<div class="nav fl">
				<ul>
					<li><a href="liebiao.html" target="_blank">小米手机</a></li>
					<li><a href="">红米</a></li>
					<li><a href="">平板·笔记本</a></li>
					<li><a href="">电视</a></li>
					<li><a href="">盒子·影音</a></li>
					<li><a href="">路由器</a></li>
					<li><a href="">智能硬件</a></li>
					<li><a href="">服务</a></li>
					<li><a href="">社区</a></li>
				</ul>
			</div>
			<div class="search fr">
				<form action="" method="post">
					<div class="text fl">
						<input type="text" class="shuru"  placeholder="小米6&nbsp;小米MIX现货">
					</div>
					<div class="submit fl">
						<input type="submit" class="sousuo" value="搜索"/>
					</div>
					<div class="clear"></div>
				</form>
				<div class="clear"></div>
			</div>
		</div>
<!-- end banner_x -->
<!-- self_info -->
	<div class="grzxbj">
		<div class="selfinfo center">
		<div class="lfnav fl">
			<div class="ddzx">订单中心</div>
			<div class="subddzx">
				<ul>
					<li><a href="./dingdanzhongxin.html" >我的订单</a></li>

				</ul>
			</div>
			<div class="ddzx">个人中心</div>
			<div class="subddzx">
				<ul>
					<li><a href="./self_info.html" style="color:#ff6700;font-weight:bold;">我的个人中心</a></li>
					<li><a href="zhengjiashouji.html">上架商品</a></li>

				</ul>
			</div>
		</div>
		<div class="rtcont fr">
			<div class="grzlbt ml40">我的资料</div>
            <div class="subgrzl ml40"><span>id</span><span><input type="text" class="update" id="uid"></span><span><a href="">编辑</a></span></div>
            <div class="subgrzl ml40"><span>昵称</span><span> <input type="text" class="update" id="uname"></span><span><a href="">编辑</a></span></div>
			<div class="subgrzl ml40"><span>密码</span><span> <input type="text" class="update"  id="upassword"></span><span><a href="">编辑</a></span></div>
			<div class="subgrzl ml40"><span>手机号</span><span> <input type="text" class="update"  id="uphone"></span><span><a href="">编辑</a></span></div>
			<div class="subgrzl ml40"><span>地址</span><span> <input type="text" class="update" id="uaddress"></span><span><a href="">编辑</a></span></div>
			<div class="subgrzl ml40"><span>状态</span><span> <input type="text" class="update" id="uisdelete"></span><span><a href="">编辑</a></span></div>
			<div class="subgrzl ml40"> <button id="subdate">提交修改</button></div>

		</div>
		<div class="clear"></div>
		</div>
	</div>
<!-- self_info -->

    <footer class="mt20 center" style="display: flex;justify-content: center;align-items: center;flex-direction: column;">
        <div class="mt20">小米商城|MIUI|米聊|多看书城|小米路由器|视频电话|小米天猫店|小米淘宝直营店|小米网盟|小米移动|隐私政策|Select Region</div>
        <div>©mi.com 京ICP证110507号 京ICP备10046444号 京公网安备11010802020134号 京网文[2014]0059-0009号</div>
        <div>违法和不良信息举报电话：185-0130-1238，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</div>
    </footer>
	</body>
</html>